package com.billard.utils;

public class UserIdUtil {
    // 创建一个用户上下文工具类  线程本地变量存储类。
        private static final ThreadLocal<Long> userIdThreadLocal = new ThreadLocal<>();

        public static void setUserId(Long userId) {
            userIdThreadLocal.set(userId);
        }// 设置当前线程的用户ID

        public static Long getUserId() {
            return userIdThreadLocal.get();
        }// 获取当前线程的用户ID

        public static void remove() {
            userIdThreadLocal.remove();
        }
}
